package com.bss.dao;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.andy.basics.Dao;
import com.bss.model.Attendent;
import com.bss.model.Patient;

@Repository
public class AttendentDao extends Dao<Attendent> {

	@SuppressWarnings("unchecked")
	@Transactional
	public List<Attendent> findAllForPatient(final Patient patient, final String condition) {

		Query query = getEntityManager().createQuery("from " + Attendent.class.getName() + " where patient = ? and " + condition);

		query.setParameter(1, patient);

		List<Attendent> list = query.getResultList();

		return list;
	}

}
